unit inversorObra;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, DBCtrls, Grids, DBGrids, RXDBCtrl, Mask, ToolEdit,
  Provider, SqlExpr, DB, DBClient, DBLocal, DBLocalS, DateUtils;

type
  TfrmInversorObra = class(TForm)
    lblFechaIni: TLabel;
    edtFechaIni: TDateEdit;
    lblFechaFin: TLabel;
    edtFechaFin: TDateEdit;
    grdInversorObra: TRxDBGrid;
    Label2: TLabel;
    DBText1: TDBText;
    btnCargar: TButton;
    cds: TSQLClientDataSet;
    s: TDataSource;
    cdsID_INVERSOR: TSmallintField;
    cdsAPENOM: TStringField;
    cdsDENOMINACION: TStringField;
    cdsSUBT: TFloatField;
    cdstotal: TAggregateField;
    procedure btnCargarClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure grdInversorObraTitleClick(Column: TColumn);
  private
    { Private declarations }
  public
    constructor CreateNuevo(AOwner: TComponent);
  end;

var
  frmInversorObra: TfrmInversorObra;

implementation

{$R *.dfm}

{ TfrmInversorObra }

constructor TfrmInversorObra.CreateNuevo(AOwner: TComponent);
begin
  inherited Create(Aowner);
  self.edtFechaIni.Date := IncYear(now, -1);
  self.edtFechaFin.Date := now;
  self.ShowModal;
end;

procedure TfrmInversorObra.btnCargarClick(Sender: TObject);
begin
  self.cds.Close;
  self.cds.Params[0].AsString := FormatDateTime('mm/dd/yy', StrToDate(self.edtFechaFin.EditText));
  self.cds.Params[1].AsString := FormatDateTime('mm/dd/yy', incDay(StrToDate(self.edtFechaIni.EditText)));
  self.cds.Open;
end;

procedure TfrmInversorObra.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  self.cds.Close;
end;

procedure TfrmInversorObra.grdInversorObraTitleClick(Column: TColumn);
begin
  self.cds.IndexFieldNames := Column.FieldName;
end;

end.
